import Vue from "vue";
import VueRouter from 'vue-router';

import Login from '@/views/login'
import Layout from '@/views/Layout'

// 首页
import Welcome from "@/views/welCome"
// 素材管理
import Imags from '@/views/imags'
// 发布文章
import Article from '@/views/article'
// 内容管理
import Content from '@/views/content'
// 评论管理
import Comment from '@/views/comment'
// 粉丝管理
import Fans from '@/views/fans'
// 设置
import Seting from '@/views/seting'

import auth from "@/utils/auth"
Vue.use(VueRouter);

// 路由规则
const routes = [
    {path:  '/login' , component: Login , },
    {
        path: '/', component: Layout,children: [
        {path: '/', component: Welcome },
        {path: '/imags', component: Imags },
        {path: '/article', component: Article },
        {path: '/content', component: Content },
        {path: '/comment', component: Comment },
        {path: '/fans', component: Fans },
        {path: '/seting', component: Seting },
    ]},
]

// 路由实例
const router = new VueRouter({ routes })
// 导航守卫 
// router.beforeEach((to, form, next) => {
//     const { getUser } = auth 
//     if (to.path !== '/login' && !getUser().token) return next('/login')
//     next()
// })

// 导出路由实例
export default router